package com.dayuanit.dy15.atm.controller;

import com.dayuanit.dy15.atm.dto.CardDTO;
import com.dayuanit.dy15.atm.dto.ResponseDTO;
import com.dayuanit.dy15.atm.entity.AtmCard;
import com.dayuanit.dy15.atm.entity.AtmUser;
import com.dayuanit.dy15.atm.service.AtmCardService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * (AtmCard)表控制层
 *
 * @author makejava
 * @since 2020-05-23 11:48:32
 */
@RestController
@RequestMapping("atmCard")
public class AtmCardController extends BaseController{
    /**
     * 服务对象
     */
    @Resource
    private AtmCardService cardService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public AtmCard selectOne(Long id) {
        return this.cardService.queryById(id);
    }


    @GetMapping
    public ResponseDTO listBankCards(HttpServletRequest request){
        List<CardDTO> cardDTOS = cardService.listBankCards(getUserId(request));
        return ResponseDTO.success().data("cardDTOS",cardDTOS);
    }

}
